package m.html.element.other;

import m.html.element.Element;
import m.html.element.attr.Size;
import m.system.util.StringUtil;

public abstract class InputElement extends Element implements IElement {
	protected InputElement(String tagName) {
		super(tagName);
	}
	protected IElement viewElement;
	public IElement toViewElement(){
		return viewElement;
	};
	public InputElement setViewElement(IElement ele){
		this.viewElement=ele;
		return this;
	}
	public InputElement setViewContent(IElement ele){
		this.viewElement=Element.tag("div").A("class","input-view-box").E(ele);
		return this;
	}
	//字段
	public String getField() {
		return this.getAttr("v-model:value");
	}
	public InputElement setField(String field) {
		this.A("v-model:value",field);
		return this;
	}
	//尺寸
	public Size getSize() {
		String size=this.getAttr("size");
		if(StringUtil.isSpace(size)) {
			return null;
		}else if(size.equals(Size.DEFAULT.toString())) {
			return Size.DEFAULT;
		}else if(size.equals(Size.SMALL.toString())) {
			return Size.SMALL;
		}else if(size.equals(Size.LARGE.toString())) {
			return Size.LARGE;
		}else {
			return null;
		}
	}
	public InputElement setSize(Size size) {
		this.A("size",size.toString());
		return this;
	}
	//空提示
	public String getPlaceholder() {
		return this.getAttr("placeholder");
	}
	public InputElement setPlaceholder(String placeholder) {
		this.A("placeholder",placeholder);
		return this;
	}
	//禁用
	public String getDisabled() {
		return this.getAttr(":disabled");
	}
	public InputElement setDisabled(String disabled) {
		this.A(":disabled",disabled);
		return this;
	}
}
